package com.example.hello;


import android.content.Context;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import androidx.annotation.NonNull;

public class MyAdapter extends ArrayAdapter {
    public MyAdapter(@NonNull Context context, int resource, @NonNull ArrayList<HashMap<String,String>> list) {
        super(context, resource, list);
    }
    public View getView(int position, View convertView, ViewGroup parent) {
        View itemView=convertView;
        if(itemView==null){
            itemView= LayoutInflater.from(getContext()).inflate(R.layout.list_item,parent,
                    false);
        }
        Map<String,String> map=(Map<String,String>)getItem(position);
        TextView country=(TextView)itemView.findViewById(R.id.item_title);
        TextView rate=(TextView)itemView.findViewById(R.id.item_detail);
        country.setText("Country:"+map.get("country"));
        rate.setText("Rate:"+map.get("rate"));

     return itemView;
    }

}
